﻿using System;
using Avalonia.Controls;
using Avalonia.Layout;

namespace iOSClub.App.Desktop.Controls;

public class EmptyControl : StackPanel
{

    private readonly string text = "";
    public EmptyControl()
    {
        
    }

    public EmptyControl(string _text)
    {
        text = _text;
    }
    protected override void OnInitialized()
    {
        base.OnInitialized();
        var icon = new Avalonia.Svg.Skia.Svg(
            new Uri("avares://iOSClub.App.Desktop/Assets/"))
        {
            Path = "/Assets/empty.svg", Height = 100,
            HorizontalAlignment = HorizontalAlignment.Center,
            VerticalAlignment = VerticalAlignment.Center,
        };
        Children.Add(icon);

        var textBlock = new TextBlock()
        {
            Text = string.IsNullOrEmpty(text) ? "暂无数据" : text,
            HorizontalAlignment = HorizontalAlignment.Center,
            VerticalAlignment = VerticalAlignment.Center,
            FontSize = 20
        };

        Children.Add(textBlock);
    }
}